package com.zxtyshangjia.zxtyjms;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.content.LocalBroadcastManager;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.zxtyshangjia.zxtyjms.login.activity.LoginActivity;
import com.zxtyshangjia.zxtyjms.login.activity.ModifyPasswordActivity;
import com.zxtyshangjia.zxtyjms.utils.SpUtils;

/**
 * Created by 18222 on 2017/11/13.
 * 设置页面
 */

public class SetActivity extends Activity {

    /**
     *  修改密码
     */
    private LinearLayout mModifyPassword;

    /**
     *  退出登录
     */
    private TextView mDropOut;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_set);
        bindView();
        initListener();
    }

    private void initListener() {
        mModifyPassword.setOnClickListener(mClickListener);
        mDropOut.setOnClickListener(mClickListener);
    }

    private void bindView() {
        mModifyPassword = (LinearLayout) findViewById(R.id.modify_password_ll);
        mDropOut = (TextView) findViewById(R.id.drop_out_tv);
    }


    //点击事件
    private View.OnClickListener mClickListener = new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if(view.getId() == mModifyPassword.getId()){
                //修改密码 跳转修改密码页
                Intent intent = new Intent(SetActivity.this,ModifyPasswordActivity.class);
                startActivity(intent);

            }else if(view.getId() == mDropOut.getId()){
                //退出登录
                LocalBroadcastManager manager = LocalBroadcastManager.getInstance(SetActivity.this);
                manager.sendBroadcast(new Intent(MainActivity.class.getName()));
                Intent intent = new Intent(SetActivity.this,LoginActivity.class);
                startActivity(intent);
                finish();
                SpUtils.getInstance(SetActivity.this).save("is_Login",false);

            }
        }
    };

}
